//#region demo
import * as THREE from "three";
//#region import
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
//#endregion import

//#region common
// 场景
const scene = new THREE.Scene();
// 相机
const camera = new THREE.PerspectiveCamera(
    45,
    window.innerWidth / window.innerHeight,
    1,
    500
);
camera.lookAt(0, 0, 0);
camera.position.set(10, 20, 40);
// 渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
//#endregion common

//#region orbit-controls
new OrbitControls(camera, renderer.domElement);
//#endregion orbit-controls

//#region box
const geometry = new THREE.BoxGeometry(10, 10, 10);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
//#endregion box

//#region animate
function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}

animate();
//#endregion animate
//#endregion demo
